package com.maoxx.humanresourcemanage_service.controller;

import com.maoxx.humanresourcemanage_service.dto.ResponseDTO;
import com.maoxx.humanresourcemanage_service.entity.Salary;
import com.maoxx.humanresourcemanage_service.service.SalaryService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @className: SalaryController
 * @author: Maoxx
 * @date: 2024/11/16 14:53
 * @Version: 1.0
 * @description:
 */

@RestController
@RequestMapping("/salary")
public class SalaryController {


    @Resource
    private SalaryService salaryService;

    @ApiOperation("分页条件查询")
    @GetMapping
    public ResponseDTO list(@RequestParam(defaultValue = "1") Integer current, @RequestParam(defaultValue = "10") Integer size, String name, String month) {
        return this.salaryService.list(current, size, name, month);
    }


    @ApiOperation("设置工资")
    @PostMapping("/set")
    public ResponseDTO setSalary(@RequestBody Salary salary) {
        return this.salaryService.setSalary(salary);
    }

    @ApiOperation("数据导出接口")
    @GetMapping("/export/{month}")
    public ResponseDTO export(HttpServletResponse response, @PathVariable String month) throws IOException {
        return this.salaryService.export(response,month);
    }

    @ApiOperation("数据导入接口")
    @PostMapping("/import")
    public ResponseDTO imp(MultipartFile file) throws IOException {
        return this.salaryService.imp(file);
    }
}
